<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/xadmin/css/font.css}">
    <link rel="stylesheet" th:href="@{/xadmin/css/xadmin.css}">
    <script th:src="@{/xadmin/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/xadmin/js/xadmin.js}"></script>
</head>
<body>
<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <blockquote class="layui-elem-quote" th:text="'当前时间: '+${nowTime}+'      第'+${nowWeek}+'周'"></blockquote>
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">本周宿舍分数</div>
                <div th:if="${#lists.isEmpty(apartmentScoreList)}">
                    <div class="layui-card-body">无</div>
                </div>
                <div th:each="p : ${apartmentScoreList}">
                    <div class="layui-card-body">
                        <li th:text="'分数: '+${p.scoreStr}"></li>
                        <li th:text="'备注: '+${p.remark}"></li>
                        <li th:text="'时间: '+${#dates.format(p.createTime, 'yyyy-MM-dd HH:mm:ss')}"></li>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">本周学生会扣分</div>
                <div th:if="${#lists.isEmpty(unionScoreList)}">
                    <div class="layui-card-body">无</div>
                </div>
                <div th:each="p : ${unionScoreList}">
                    <div class="layui-card-body">
                        <li th:text="'分数: '+${p.scoreStr}"></li>
                        <li th:text="'备注: '+${p.remark}"></li>
                        <li th:text="'时间: '+${#dates.format(p.createTime, 'yyyy-MM-dd HH:mm:ss')}"></li>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">公告</div>
                <div class="layui-card-body">
                    <table class="layui-table" id="test" lay-filter="test"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['table', 'form'], function () {
        var table = layui.table
            , form = layui.form
            , layer = layui.layer;

        var load = layer.load(1);
        getTable();
        layer.close(load);

        function getTable() {
            table.render({
                elem: '#test',
                url: '/noticeStu',
                toolbar: false,
                skin: 'nob',
                even: true,
                size: 'sm',
                cols: [
                    [
                        {
                            field: 'createTime',
                            width: 150,
                            templet: '<div>{{layui.util.toDateString(d.createTime*1, `yyyy-MM-dd HH:mm:ss`)}}</div>',
                            title: '时间'
                        },
                        {field: 'title', minWidth: 200, title: '标题'},
                        {field: 'type', width: 100, title: '类型', align: 'right'}
                    ]
                ],
                page: true,
                limits: [10, 20, 50, 100, 500, 1000]
            });
        }

        table.on('row(test)', function (obj) {
            sessionStorage.setItem('notice', JSON.stringify(obj.data))
            layer.open({
                title: '公告',
                type: 2,
                area: ['600px', '400px'],
                content: '/stu/getPage?name=notice'
            });
            // console.log(obj.tr) //得到当前行元素对象
            // console.log(obj.data) //得到当前行数据
            //obj.del(); //删除当前行
            //obj.update(fields) //修改当前行数据
        });
    });
</script>
</html>